package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC217 {
    public long startExecuteTime = System.currentTimeMillis();

    //    Input: [1,1,1,3,3,4,3,2,4,2]
//    Output: true
    public boolean containsDuplicate(int[] arr) {
        Set<Integer> dict = new HashSet<>();
        for (int i = 0; i < arr.length; i++) {
            if (dict.contains(arr[i])) {
                return true;
            } else {
                dict.add(arr[i]);
            }
        }

        return false;
    }


    public static void main(String[] args) {
        LC217 an = new LC217();
        int[] arr = InputUtil.toIntegerArray("[1,1,1,3,3,4,3,2,4,2]");
        System.out.println(an.containsDuplicate(arr));

        System.out.println("\nanswer total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
